
import React from 'react'
import { NavBar, Icon } from 'antd-mobile';
import creatHistory from 'history/createHashHistory'
const history = creatHistory();
const NavBarHoc = (title, isneedSerach) => (Wrap) => {

    return class newWrap extends React.Component {
        static displayName = `Navi-Hoc-${getDisplayName(Wrap)}`
        render() {
            return (
                <div>
                    <NavBar
                        mode="light"
                        icon={<Icon type="left" />}
                        onLeftClick={() => history.goBack()}
                        rightContent={isneedSerach ? [
                            <Icon key="0" type="search" style={{ marginRight: '16px' }} />,
                            <Icon key="1" type="ellipsis" />,
                        ] : ''}
                    >{title}</NavBar>
                    <Wrap />
                </div>

            )
        }
    }

}
function getDisplayName(Wrap) {
    return Wrap.displayName || Wrap.name || 'Component'
}
export default NavBarHoc